from kivy.app import App
from kivy.lang import Builder
from kivy.tools.packaging.pyinstaller_hooks.pyi_rth_kivy import root
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
# Create both screens. Please note the root.manager.current: this is how
# you can control the ScreenManager from kv. Each screen has by default a
# property manager that gives you the instance of the ScreenManager used.
Builder.load_string("""
<MenuScreen>:
    BoxLayout:
        Button:
            text: 'Goto settings'
            on_press: root.manager.current = 'settings'
        Button:
            text: 'Quit'

<SettingsScreen>:
    BoxLayout:
        Button:
            text: 'My settings button'
        Button:
            text: 'Back to menu'
            on_press: root.manager.current = 'menu'
""")

# Declare both screens
class MenuScreen(Screen):
    pass

class SettingsScreen(Screen):
    pass

class TestApp(App):

    def build(self):
        # Create the screen manager
        sm = ScreenManager()
        ms = Screen()
        se = ScreenManager()
        se_box = BoxLayout()
        # se_box.add_widget(Button(text='Goto settings',on_press=se.current.a)
        sm.add_widget()
        sm.add_widget()

        return sm

if __name__ == '__main__':
    TestApp().run()